<script setup lang="ts">
import { onMounted, onBeforeUnmount, watch, ref, reactive } from 'vue'
import { storeToRefs } from 'pinia'
import { useFinanceStore } from '@/stores/module/finance'
const FinanceStore = useFinanceStore() // 创建store实例
const { getSalesCompare } = storeToRefs(FinanceStore)

</script>
<template>
  <card-box>
    <ul class="grand-total">
      <li>
        <span>{{ getSalesCompare?.info?.money }}</span>
        <span
          :class="{
            'red-coro': !getSalesCompare?.info?.amountRatio.includes('-'),
            'green-coro': getSalesCompare?.info?.amountRatio.includes('-'),
          }"
          >{{
            getSalesCompare?.info?.moneyNubem.replace(
              /(\d{3})(\d{2})/,
              '$1,$2'
            )
          }}{{ getSalesCompare?.info?.units }}</span
        >
      </li>
      <li>
        <div>
          <img
            src="@/assets/images/FinancialPicture/down.png"
            alt=""
            v-if="getSalesCompare?.info?.amountRatio.includes('-')"
          />
          <img src="@/assets/images/FinancialPicture/up.png" alt="" v-else />

          <span
            :class="{
              'red-coro': !getSalesCompare?.info?.amountRatio.includes('-'),
              'green-coro': getSalesCompare?.info?.amountRatio.includes('-'),
            }"
            >{{ getSalesCompare?.info?.amountRatio }}</span
          >
        </div>

        <span>{{ getSalesCompare?.info?.profit }}</span>
      </li>
    </ul>
  </card-box>
</template>

<style lang="scss" scoped>
.grand-total {
  width: 100%;
  height: 95px;
  display: flex;
  li {
    display: flex;
  }
  li:first-child {
    width: 45%;
    justify-content: center;
    flex-direction: column;
    span {
      margin-top: 10px;
      margin-left: 30px;
    }
  }
  li:last-child {
    width: 55%;
    height: 78px;
    justify-content: end;
    align-items: end;
    span {
      margin-right: 20px;
    }
  }
  img {
    width: 20px;
    height: 20px;
  }
}

.red-coro {
  color: #eb3e60;
}
.green-coro {
  color: #00bfa5;
}
</style>
